/** @jsxImportSource @emotion/react */
import * as React from "react";
import {RepLink, ReportViewProps,} from "../../common/base";
import {末尾链接, } from "../../common/rarelyVary";
import {CCell, Cell, Embed, RCell, Table, TableBody, TableRow, Text, useTheme} from "customize-easy-ui-component";
import {ReportFirstPageHeadCyNmaNQR, } from "../../valve/rarelyVary";
import {useThreeColumnView} from "../../hook/useThreeColumnSubr";
import {config设备概况} from "./Regular.O-1";
import {reviseBusiness} from "../rarelyVary";

export const ReportView: React.FunctionComponent<ReportViewProps> = ({
    repId,   source: orc,  verId,rep,
}) => {
    // const [rootMenu]=useRepMenuDirItems(VsProjects默认, orc.Projects, `/reportView/${rep?.modeltype}/ver/${verId}/${repId}`);
  return (
    <React.Fragment>
        <div css={{"@media not print": {marginTop: '1rem', marginBottom: '1rem'}}}>
          <CertificatePage orc={orc} rep={rep}/>
        </div>
        {末尾链接({template: rep?.modeltype, verId, repId: repId || ''})}
    </React.Fragment>
  );
}
//固定打印一张纸的：注意底下的调整  "@media print": {height:'82vh',} }
export const CertificatePage= ({ orc, rep, children} : { orc: any,rep: any,children?: React.ReactNode}
) => {
    const theme= useTheme();
    const [devInfovw,_2]=useThreeColumnView({orc, config:config设备概况,slash:true,split:[13]});
    const callback = () => {
        return <div  css={{"@media print": {height:'100vh', overflowY: 'hidden',
                        top: '-0.3rem', position: 'relative'
            } }}>
            { ReportFirstPageHeadCyNmaNQR({theme,rep, mbbm:'FJB/GB 10071-0-2021'}) }
            <div css={{
                "@media print": {
                    display: 'flex',
                    flexDirection: 'column',
                    justifyContent: 'space-around',
                    height: 'calc(100vh - 4.5rem)',     //剪掉上面头部的高度 [#需调整]
                }
            }}>
                <Text variant="h3" css={{textAlign:'center',lineHeight:'0.9', "@media print": {fontSize: theme.fontSizes[5],},}}>
                   锅炉安装、改造和重大修理监督检验证书
                </Text>
                <div>
                    <div css={{display: 'flex',justifyContent: 'space-between',flexDirection: 'row-reverse',}}>
                        <Text css={{marginRight: '2rem',fontSize: '1rem'
                        }}>证书编号：{rep.isp?.no}</Text>
                    </div>
                    <Table className="FixHei82"  fixed={ ["16.1%", "23%", "14.1%", "14.1%", "9%", "%"] }  css={ {borderCollapse: 'collapse',
                                            "@media print": {height:'82vh',} } }
                            tight  miniw={800}>
                        <TableBody>
                            <RepLink rep={rep} tag={'Survey'}>
                                {devInfovw}
                                {/*顺序上优先的height:'fill-available'被安排上了，而后面的就无效*/}
                                <TableRow css={{"@media print": {height:'fill-available'}}}><Cell colSpan={6} >
                                    <div css={{whiteSpace: 'pre-wrap', "@media print": {height:'fill-available'}}}>
                                        <Text css={{fontSize: '0.8rem'}}>说明：（可附页）</Text><br/>
                                        {orc?.说明 ?? '／'}
                                    </div>
                                </Cell></TableRow>
                            </RepLink>
                            <TableRow>
                                <CCell colSpan={6}>
                                    <Table fixed={["24%", "39%", "6%", "%"]}
                                           css={{borderCollapse: 'collapse', "@media print": {height:'fill-available'},} }  tight  miniw={800}>
                                        <TableBody>
                                            <TableRow>
                                                <Cell css={{border:'none',textIndent:'2rem'}} colSpan={4}>按照《中华人民共和国特种设备安全法》、《特种设备安全监察条例》的规定，该锅炉的
                                                    {reviseBusiness(orc?.检验类别) ??'／'}，经我机构监督检验，安全性能符合《锅炉安全技术规程》规定的基本安全要求，特发此证书。</Cell>
                                            </TableRow>
                                            <TableRow>
                                                <Cell css={{border:'none',padding:0}} colSpan={4}>
                                                    <Embed css={{width: "96px",margin: "auto",top: '-0.15rem',height:'2rem'}} width={43} height={43}>
                                                        {/*<FadeImage src={Img_TS}/>*/}
                                                    </Embed>
                                                </Cell>
                                            </TableRow>
                                            <TableRow css={{"@media print": {height:'3rem'} }}>
                                                <RCell css={{border:'none',}}>监督检验人员：</RCell>
                                                <Cell css={{border:'none',}}>机erter</Cell>
                                                <RCell css={{border:'none',}}>日期：</RCell>
                                                <Cell css={{border:'none',}}></Cell>
                                            </TableRow>
                                            <TableRow css={{"@media print": {height:'2rem'} }}>
                                                <RCell css={{border:'none',}}>审   核：</RCell>
                                                <Cell css={{border:'none',}}></Cell>
                                                <RCell css={{border:'none',}}>日期：</RCell>
                                                <Cell css={{border:'none',}}>2024-04-10</Cell>
                                            </TableRow>
                                            <TableRow css={{"@media print": {height:'2rem'} }}>
                                                <RCell css={{border:'none',}}>批   准：</RCell>
                                                <Cell css={{border:'none',}}></Cell>
                                                <RCell css={{border:'none',}}>日期：</RCell>
                                                <Cell css={{border:'none',}}>2024-04-10</Cell>
                                            </TableRow>
                                            <TableRow>
                                                <RCell css={{border:'none',}}>监检机构：</RCell>
                                                <Cell colSpan={2} css={{border:'none',}}>{rep?.isp?.ispu?.name}</Cell>
                                                <CCell css={{border:'none',}}>（监督检验机构检验专用章）</CCell>
                                            </TableRow>
                                            <TableRow css={{"@media print": {height:'fill-available'} }}>
                                                <RCell  css={{border:'none',}}>监督检验机构核准证号：</RCell>
                                                <Cell  colSpan={2} css={{border:'none',}}>{rep?.isp?.ispu?.agency?.apno}</Cell>
                                                <CCell css={{border:'none',}}>2024-04-10</CCell>
                                            </TableRow>
                                        </TableBody>
                                    </Table>
                                </CCell>
                            </TableRow>
                        </TableBody>
                    </Table>
                </div>
                <Text css={{fontSize:'0.7rem'}}>注：本证书一式三份，一份监检机构存档，两份送施工单位，其中一份由施工单位随竣工资料交付使用(建设)单位。
                </Text>
            </div>
        </div>
    }
    // const [renderAll]=useFolder(callback,'检验证书折叠',false);
    return <>
        <div id="Certificate"/>
        {callback()}
    </>;
};
